package com.zretc.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Md5Util {
	public static String md5(String password) {
		try {
			//创建消息摘要
			MessageDigest messageDigest=MessageDigest.getInstance("md5");
			messageDigest.update(password.getBytes());//更新加密数据
			byte[] encode=messageDigest.digest();//获取加密后的数据
			BigInteger bigInteger=new BigInteger(1, encode);
			return bigInteger.toString(16);
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		return null;
	}
}
